home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / chrome / content / searchchannel.js < prev    next >
Encoding:
JavaScript  |  2007-11-12  |  3.2 KB  |  91 lines

  1. /*
  2. # Miro - an RSS based video player application
  3. # Copyright (C) 2005-2007 Participatory Culture Foundation
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  18. */
  19.  
  20. var pybridge = Components.classes["@participatoryculture.org/dtv/pybridge;1"].
  21.                 getService(Components.interfaces.pcfIDTVPyBridge);
  22.  
  23. function onload() {
  24.     var channels = window.arguments[0]['channels'].QueryInterface(Components.interfaces.nsICollection);
  25.     var count = channels.Count();
  26.     var widget = getWidget ("menulist-channel");
  27.     var i;
  28.     for (i = 0; i < count; i++) {
  29.         widget.appendItem (channels.GetElementAt (i).QueryInterface(Components.interfaces.nsISupportsString).data);
  30.     }
  31.     var engines = window.arguments[0]['engines'].QueryInterface(Components.interfaces.nsICollection);
  32.     count = engines.Count();
  33.     widget = getWidget ("menulist-searchengine");
  34.     for (i = 0; i < count; i++) {
  35.         widget.appendItem (engines.GetElementAt (i).QueryInterface(Components.interfaces.nsISupportsString).data);
  36.     }
  37.     getWidget("textbox-term").value = window.arguments[0]['defaultTerm'];
  38.     getWidget("menulist-channel").selectedIndex = window.arguments[0]['defaultChannel'];
  39.     getWidget("menulist-searchengine").selectedIndex = window.arguments[0]['defaultEngine'];
  40.     getWidget("textbox-url").value = window.arguments[0]['defaultURL'];
  41.     getWidget("radio-style").selectedIndex = window.arguments[0]['defaultStyle'];
  42.     updateUI();
  43. }
  44.  
  45. function updateUI ()
  46. {
  47.     toggledEnable("radio-channel", "menulist-channel")
  48.     toggledEnable("radio-searchengine", "menulist-searchengine")
  49.     toggledEnable("radio-url", "textbox-url")
  50. }
  51.  
  52. function toggledEnable (toggle, widget)
  53. {
  54.     toggle = getWidget (toggle);
  55.     widget = getWidget (widget);
  56.     if (toggle.selected) {
  57.         widget.disabled = "";
  58.     } else {
  59.     widget.disabled = "true";
  60.     }
  61. }
  62.  
  63. function onaccept ()
  64. {
  65.     term = getWidget ("textbox-term").value;
  66.     var loc;
  67.     var style;
  68.     if (getWidget("radio-channel").selected) {
  69.     style = 0;
  70.     loc = getWidget("menulist-channel").selectedIndex;
  71.     } else if (getWidget("radio-searchengine").selected) {
  72.     style = 1;
  73.     loc = getWidget("menulist-searchengine").selectedIndex;
  74.     } else if (getWidget("radio-url").selected) {
  75.     style = 2;
  76.     loc = getWidget("textbox-url").value;
  77.     }
  78.     pybridge.handleSearchChannelDialog(window.arguments[0]['id'], 0, term, style, loc)
  79. }
  80.  
  81. function oncancel ()
  82. {
  83.     pybridge.handleSearchChannelDialog(window.arguments[0]['id'], 1, "", 0, "")
  84. }
  85.  
  86. function getWidget(widgetID)
  87. {
  88.     return document.getElementById(widgetID);
  89. }
  90.  
  91.